cmake_minimum_required(VERSION 3.16)
project(buffercapture-qml VERSION 1.0 LANGUAGES C CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Set up AUTOMOC and some sensible defaults for runtime execution
# When using Qt 6.3, you can replace the code block below with
# qt_standard_project_setup()
set(CMAKE_AUTOMOC ON)
include(GNUInstallDirs)

find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS 3DCore 3DExtras 3DInput 3DLogic 3DQuick 3DQuickExtras 3DRender Gui Qml Quick)

add_executable(buffercapture-qml WIN32 MACOSX_BUNDLE
    main.cpp
)
qt_add_qml_module(buffercapture-qml
    URI buffercapture_qml
    VERSION ${PROJECT_VERSION}
    QML_FILES
        BufferSetterScene.qml
        main.qml
        ComputeFrameGraph.qml
        ComputeMaterial.qml
    RESOURCES
        bufferSetter.comp
    NO_RESOURCE_TARGET_PATH
)

target_link_libraries(buffercapture-qml PRIVATE
    Qt${QT_VERSION_MAJOR}::3DCore
    Qt${QT_VERSION_MAJOR}::3DExtras
    Qt${QT_VERSION_MAJOR}::3DInput
    Qt${QT_VERSION_MAJOR}::3DLogic
    Qt${QT_VERSION_MAJOR}::3DQuick
    Qt${QT_VERSION_MAJOR}::3DQuickExtras
    Qt${QT_VERSION_MAJOR}::3DRender
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Gui
    Qt${QT_VERSION_MAJOR}::Qml
    Qt${QT_VERSION_MAJOR}::Quick
)

install(TARGETS buffercapture-qml
    BUNDLE DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Consider using qt_generate_deploy_app_script() for app deployment if
# the project can use Qt 6.3. In that case rerun qmake2cmake with
# --min-qt-version=6.3.
